/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-30 11:01:15
 * @Description  : 试卷相关接口
 */

import type {
  PaperCreateReq,
  PaperPageRes,
  PaperReq,
  PaperUpdateReq
} from '@/types/paper'
import request from '@/utils/request'

// 分页查询试卷接口
export const getPaperByPage = (params?: PaperReq) => {
  return request.get<PaperPageRes>('/paper/list', { params })
}

// 添加试卷接口
export const createPaper = (data: PaperCreateReq) => {
  return request.post('/paper/create', data)
}

// 更新试卷接口
export const updatePaper = (data: PaperUpdateReq) => {
  return request.put('/paper/update', data)
}

// 试卷排序接口
export const sortPaper = (paperIds: string[]) => {
  return request.put('/paper/sort', { paperIds })
}

// 试卷删除接口
export const delPaper = (paperIds: string[], picCode?: string) => {
  return request.delete('/paper/delete', { data: { paperIds, picCode } })
}

// 试卷批量变更章节接口
export const changeChapterPaper = (paperIds: string[], chapterId?: string) => {
  return request.put('/paper/changeChapter', {  paperIds, chapterId  })
}


// 试卷导出接口
export const exportPaper = (paperId: string,hasAnswer: boolean) => {
  return request.post('/paper/export', { paperId,hasAnswer})
}

// 根据id获取试卷详情接口
export const getPaperById = (paperId: string) => {
  return request.get('/paper/list/id', { params: { paperId } })
}
